package com.touchalachs.core;

import android.app.Activity;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Window;

public abstract class CoreActivity extends Activity {
	private GameView v;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		v = createView(getScreenSize());
		setContentView(v);
	}

	abstract protected GameView createView(Point screenSize);

	@SuppressWarnings("deprecation")
	private Point getScreenSize() {
		Point size = new Point(
				getWindowManager().getDefaultDisplay().getWidth(), 
				getWindowManager().getDefaultDisplay().getHeight());
		// Point size = new Point();
		// getWindowManager().getDefaultDisplay().getSize(size);
		return size;
	}

	@Override
	protected void onPause() {
		v.surfaceDestroyed(null);
		super.onPause();
		v = null;
	}

	@Override
	protected void onResume() {
		super.onResume();
		v = createView(getScreenSize());
		setContentView(v);
	}
}